﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using StockTrader.DAL.IDAL;
using StockTrader.DAL.MSSQLHelper;
using StockTrader.BusinessService.DataContract;

namespace StockTrader.DAL.SQLserver
{
    public class Language: ILanguage
    {
/*
                private SqlConnection _internalConnection;
                private SqlTransaction _internalADOTransaction = null;
        
                public void BeginADOTransaction()
                {
                    if (_internalConnection.State != System.Data.ConnectionState.Open)
                        _internalConnection.Open();
                    _internalADOTransaction = _internalConnection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
                }
                public void RollBackTransaction()
                {
                    _internalADOTransaction.Rollback();
                    _internalADOTransaction = null;
                }
                public void CommitADOTransaction()
                {
                    _internalADOTransaction.Commit();
                    _internalADOTransaction = null;
                }
                public void Open(string connString)
                {
                    if (_internalConnection == null)
                        _internalConnection = new SqlConnection(connString);
                    if (_internalConnection.State != ConnectionState.Open)
                        _internalConnection.Open();
                }
                public void Close()
                {
                    if (_internalConnection != null && _internalConnection.State != System.Data.ConnectionState.Closed)
                        _internalConnection.Close();
                }
        
                //SQL string
                private const string SQL_LANGUAGE_GETALL = "SELECT * FROM LANG"; 
        
                #region Parameters
                #endregion
        
                //Functions
        
        
                #region ILanguage Members
        
        
                public List<LanguageUI> GetLanguage()
                {
                    try
                    {
                        List<LanguageUI> langList = new List<LanguageUI>();
                        SqlDataReader rdr = SQLHelper.ExecuteReaderNoParm(_internalConnection, _internalADOTransaction, CommandType.Text, SQL_LANGUAGE_GETALL);
                        while (rdr.Read())
                        {
                            LanguageUI item = new LanguageUI(Convert.ToInt32(rdr["ID"]), rdr["COUNTRY"].ToString());
                            langList.Add(item);
                        }
                        rdr.Close();
                        return langList;
                    }
                    catch
                    {
                        throw;
                    }
                }
        
                #endregion*/
        
    }
}
